import unittest
from myList import MyList


class TestMySplice(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        pass

    @classmethod
    def tearDownClass(cls):
        pass

    def test01(self):
        ml = MyList([1, 2, 3, 4, 5, 6])
        actList = ml.mySplice(2, 3)
        expList = [1, 2, 6]
        self.assertEqual(expList, actList)

    def test02(self):
        ml = MyList(['a', 'b', 'c', 'd'])
        actList = ml.mySplice(1, 2)
        expList = ['a', 'd']
        self.assertEqual(expList, actList)

    def test03(self):
        ml = MyList([1])
        actList = ml.mySplice(0, 1)
        expList = []
        self.assertEqual(expList, actList)

    def test04(self):
        ml = MyList([1, 2, 'hello', 4, 5])
        actList = ml.mySplice(0, 5)
        expList = []
        self.assertEqual(expList, actList)

    def test05(self):
        ml = MyList([1, [2, 'hello'], 4, [5, 'world']])
        actList = ml.mySplice(0, 2)
        expList = [4, [5, 'world']]
        self.assertEqual(expList, actList)

    def test06(self):
        ml = MyList([1, 2, 'hello', 4, 5])
        actList = ml.mySplice(2, 0)
        expList = [1, 2, 'hello', 4, 5]
        self.assertEqual(expList, actList)

    def test07(self):
        ml = MyList([1, 2, 'hello', 4, 5])
        actList = ml.mySplice(5, 1)
        expList = ''  # 提示下标越界
        self.assertEqual(expList, actList)


if __name__ == '__main__':
    # unittestdemo.main()
    suite = unittest.TestSuite()
    testCases = unittest.TestLoader().loadTestsFromTestCase(TestMySplice)
    suite.addTests(tests=testCases)
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
